<template>
	<view>
		<view class="cont">
			<view class="margin bg-fff">
				
				<view class="text-center" >
					<image class="avatar" src="../../static/个人中心.png"></image>
				</view>
				
				<view class="fs-30 text-center">
					用户名：张三份
				</view>
				<view>
					用户详情页
					<view v-if="status">
						<button @click="unfollow">取消关注</button>
					</view>
					<view v-else >
						<button @click="follow">关注</button>
					</view>
				</view>
				<view class="flex grid">
					<view v-for="(item,index) in gridarr" class="flex flex-direction align-center padding">
						<text :class="['iconfont margin-botton-xs', item.icon]"></text>
						{{item.name}}
					</view>
					
				</view>
				<view class="flex grid ">
					<view v-for="(item,index) in gridarr" class="flex flex-direction align-center padding">
						<text :class="['iconfont margin-botton-xs', item.icon]"></text>
						{{item.name}}
					</view>
					
				</view>
				
			</view>
		</view>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				status:false,
				userid:1,
				myId:1,
				user:cc
			}
		},
		methods: {
			follow(){
				//从本地获取你的id
				this.status=false
				uni.request({
					         url: 'http://localhost:9001/user/follow',
							method: 'GET',
							data:{
									  userId: this.userid ,
									  followId:1  
								},
					              success: (res) => {
					                  console.log(res.data);
									  console.log(res.data.data);
									  this.user=res.data.data;
					              }
					       })
			}
			,
			unfollow(){
				//从本地获取你的id
				this.status=true
				uni.request({
					         url: 'http://localhost:9001/user/cancelFollow',
							method: 'GET',
							data:{
									  userId: this.userid ,
									  followId:1  
								},
					              success: (res) => {
					                  console.log(res.data);
									  console.log(res.data.data);
									  this.user=res.data.data;
					              }
					       })
			}
			
		},
		onLoad(options) {
			console.log(options);
			this.userid=options.idx;
			uni.request({
				            url: 'http://localhost:9001/user/getuser?id='+this.userid, 
							method: 'GET',
				              success: (res) => {
				                  console.log(res.data);
								  console.log(res.data.data);
								  this.user=res.data.data;
				              }
				       })
			//查询是否已经关注
		}
	}
</script>

<style>

</style>

